<template>
  <div class="bigBox">
    <div class="title">{{ newsInfo.title }}</div>
    <p class="nav">
      <span>发表时间: {{ newsInfo.add_time | deteFoemat }}</span>
      <span>点击次数: {{ newsInfo.click }}</span>
    </p>
    <hr />
    <div class="content" v-html="newsInfo.content"></div>
    <commentsub :id="id"></commentsub><!-- 子组件获取当前组件中的id -->
  </div>
</template>
<script>
//引入子组件
import commentsub from "../subcoment/comment.vue"
export default {
  data() {
    return {
      id: this.$route.params.id,
      newsInfo: {}
    };
  },
  created() {
    this.NewsInfo();
  },
  methods: {
    NewsInfo() {
      this.axios.get("api/getnew/" + this.id).then(res => {
        if (res.status == 200) {
          console.log(res.data.message[0]);
          this.newsInfo = res.data.message[0];
        }
      });
    }
  },
  components:{
      commentsub
  }
};
</script>
<style lang="less" scoped>
.bigBox {
  padding: 10px;
  .title {
    width: 100%;
    text-align: center;
    font-size: 18px;
    color: red;
  }
  .nav {
    font-size: 13px;
    display: flex;
    justify-content: space-between;
    color: greenyellow;
    padding: 5px;
  }
  .content {
    img {
      width: 100%;
    }
  }
}
</style>